<!DOCTYPE html>
<html>
<head>
	<meta charset="utf-8">
  <meta name="viewport" content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0">
  <title>HomePage</title>
  <link rel="stylesheet" href="__ROOT__/public/static/layui/css/layui.css" media="all">
  <script src="__ROOT__/public/static/layui/layui.js" charset="utf-8"></script> 
  <script type="text/javascript" src="__ROOT__/public/static/jquery-3.4.1.min.js"></script>
</head>
<body>
  <div style="margin-top: 180px;margin-left: 150px;margin-right: 150px">
    <form class="layui-form" action="">
      <div class="layui-form-item" style="text-align: center;">
        <h1  >Welcome to SJFX</h1>
      </div>
      <div class="layui-form-item">
        <label class="layui-form-label">工号</label>
        <div class="layui-input-block">
          <input type="text" name="username" lay-verify="username" autocomplete="off" placeholder="请输入工号" class="layui-input">
        </div>
      </div>
      <div class="layui-form-item">
        <label class="layui-form-label">密码</label>
        <div class="layui-input-block">
          <input type="password" lay-verify="password" name="password" placeholder="请输入密码" autocomplete="off" class="layui-input">
        </div>
      </div>
      <div class="layui-form-item" style="text-align: center;">
        <div class="layui-input-block">
          <button class="layui-btn" lay-submit="" lay-filter="clicksure">确  定</button>
          <button type="reset" class="layui-btn">重置</button>
        </div>
      </div>
    </form></div>

    <script type="text/javascript">
      layui.use('form',function () {
        var form=layui.form;
        form.verify({
          username:[/^[\d]{8,8}$/,'工号必须8位数字'],
          password:[/^[\S]{6,12}$/,'密码必须6到12位，且不能出现空格']
        });
        form.on('submit(clicksure)',function (d) { 
          jQuery.ajax({
            type:"POST",
            contentType:"application/json;charset=UTF-8",
            url:"{$baseurl}/index.php/index/dc/logincheck",
            data:JSON.stringify(d.field),
            beforeSend:function(){
              layer.msg('正在验证......');
            },
            success:function (result) {
              var x=JSON.parse(result);
              if (x.result==1) {
                window.location.href='firstpageinfo';
              }else{
                layer.msg('工号或密码错误');
              }
            }
          });
          return false;
        })
      });
    </script>
    <div class="layui-footer" style="margin-bottom: 0px;position:fixed;  bottom:0px;">
 卷面数据分析应用程序 Copyright © 2020 Math HZNU. All rights reserved.
</div>
  </body>
  </html>